<?$numCss=22;
 $ieinfo = array();
 $ie = preg_match("/; MSIE (\d)+\./", $_SERVER['HTTP_USER_AGENT'], $ieinfo)==1;
 if ($ie && $ieinfo[1] && $ieinfo[1]<7)
    $doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
 else if ($ie && $ieinfo[1] && $ieinfo[1]<8)
    $doctype = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
 else
    $doctype = '<!DOCTYPE html>';

echo $doctype;
 ?>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=7" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <?= $this->headMeta(); ?>
        <? $this->headTitle()->setPrefix(WEB_PATH);
        echo $this->headTitle();?>
        <?  $this->headLink()->appendStylesheet(STATIC_PATH . '/css/main.css?numCss=' . $numCss);
           if ($ie) $this->headLink()->appendStylesheet(STATIC_PATH . '/css/ie.css?numCss=' . $numCss);

        foreach (Zend_Registry::get("languages") as $lang=>$name) {
            if ($this->lang == $lang) continue;
            $href = $_SERVER['REQUEST_URI'];
            if (strstr($href, "/{$this->lang}/"))
                $href = str_replace("/{$this->lang}/", "/$lang/", $href);
            else
                $href .= "$lang/";
            $this->headLink(array('rel' => 'alternate', 'hreflang' => $lang, 'href' => $href), 'APPEND');
        }
        ?>
        <?=$this->headLink(); ?>
        <link rel="shortcut icon" href="<?= STATIC_PATH ?>/images/favicon.ico" />
        <link rel="search" type="application/opensearchdescription+xml" href="/opensearch_<?= $this->lang ?>.xml" title="Foofind" />
        <?= $this->jQuery()->setLocalPath(STATIC_PATH . '/js/jquery.min.js'); ?>
        <?= $this->headScript(); ?>
        <? if ($ie && $ieinfo[1]>6): ?><script type="text/javascript">$(window).load(function() { corners('.awesome', '<?= STATIC_PATH ?>/images/alert-overlay.png'); });</script><? endif; ?>
        <script type="text/javascript">if (window != top) top.location.href = location.href;</script>
        <script type="text/javascript">var _gaq = _gaq || [];_gaq.push(['_setAccount', 'UA-808946-19']);_gaq.push(['_setDomainName', '.<?=WEB_PATH?>']);_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();</script>
    </head>
    <body>
        <?if ($this->langtest):?><div id="beta_translation"><?=$this->translate("BetaTranslation", "/{$this->lang}/page/translate/?lang={$this->lang}")?></div><?endif;?>
        <div id="header" >
            <div id="header-navigation" >
                <span class="user_login_box" nowrap>
                    <?php
                    $auth = Zend_Auth::getInstance ();
                    if (!$auth->hasIdentity()) {
                        echo '<a href="/' . $this->lang . '/user/register">' . $this->translate('new user') . '</a> ' .
                        $this->translate('or') . ' ';
                        echo '<a href="/' . $this->lang . '/auth/login">' . $this->translate('login') . '</a>';
                    } else {
                        $auth_username = $auth->getIdentity()->username;
                        echo $this->translate('hello,') . '<b>&nbsp;<a href="/' .
                        $this->lang . '/profile/' . $this->escape($auth_username) . '">' . $this->escape($auth_username) . '</a></b> | ' . '<a href="/' . $this->lang . '/auth/logout">' .
                        $this->translate('logout') . '</a>';
                    } ?></span>&nbsp;&nbsp;
                <div id="select_language_box">
                   <?php
                    $langs = Zend_Registry::get("languages");
                    $activelangs = Zend_Registry::get("activelangs");
                    foreach ($langs as $lang=>$name):
                        $langlink = "/$lang/index/setlang";
                        if ($activelangs[$lang]==1) {
                            $beta = " beta";
                            $beta_lang = "<span class='beta_lang'></span>";
                            if ($this->lang==$lang) $langlink = "/$lang/page/translate?lang=$lang";
                        } else {
                            $beta = $beta_lang = "";
                        }
                        ?>
                        <a class="lang<?=($this->lang==$lang)?" active":""?>" href='<?=$langlink?>'><span class="flag <?=$lang.$beta?>"></span><?=$beta_lang?><span class="lang_name"><?=$name?></span></a>
                    <?php endforeach;?>
                    <a href='/<?=$this->lang?>/page/translate'><?=$this->translate('Other');?>...</a>
                </div>
            </div>
        </div>
        <? if ($ie && $ieinfo[1]<7): ?>
        <script type="text/javascript">$("#select_language_box a").mouseenter(function(){$("#select_language_box").addClass("deployed_languages");});
            $("#select_language_box a").mouseleave(function(){$("#select_language_box").removeClass("deployed_languages");});
        </script>
        <? endif;?>
